﻿@model PagedList<Niunan.VideoSys.Model.Video>
@using Webdiyer.WebControls.Mvc
@{
    ViewBag.Title = "视频列表";
    Niunan.VideoSys.DAL.VideomxDAL mxdal = new Niunan.VideoSys.DAL.VideomxDAL();
}

 <div class='rightinfo'>
    <div class='tools'>
        <form action="" method="get">
            <div class='toolbar'>
                <a class="layui-btn layui-btn-danger" href="javascript:delmore()"><i class="layui-icon">&#x1007;</i> 删除所选项</a>
                <a href="/Adnn1n/Video/Add" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe61f;</i> 新 增</a>
            </div>
            <div class='toolbar2'>
                <div class='layui-input-inline'>
                    <input type="text" name="key" placeholder='查询关键字' class='layui-input' />
                </div>
                <button type="submit" class='layui-btn'><i class='layui-icon'>&#xe615;</i> 搜 索</button>
            </div>
        </form>
    </div>
    <table class="layui-table">
        <thead>
            <tr>
                <th>
                    <input id="chkall" type="checkbox" class="allselect" />
                </th> 
                <th>创建时间</th>
                <th>标题</th>
                <th>图片</th>
                <th>简述</th>
                <th>集数</th>
                <th>访问量</th>
                <th></th>
            </tr>
        </thead>
        <tbody>

         @foreach (var item in Model)
         {
            <tr>
                <td><input type='checkbox' class='chkitem' value='@item.id' /> </td> 
                <td> @item.createtime </td>
                <td> @item.title</td>
                <td> <img src="@item.img" style="max-width:200px;max-height:100px;" />  </td>
                <td> @item.body </td>
                <td>@mxdal.CalcCount("videoid="+item.id)</td>
                <td> @item.visitnum </td>
                <td>
                    <a href="/Adnn1n/Video/Add/@item.id"><i class="layui-icon">&#xe642;</i>编辑</a> |
                    <a href="javascript:void(0);" onclick='delone(@item.id)'><i class="layui-icon">&#x1006;</i>删除</a> |
                    <a href="/adnn1n/videomx/index?videoid=@item.id"><i class="layui-icon">&#xe654;</i>  管理集数</a>
                </td>
            </tr>
         }
                 

        </tbody>
    </table>
    <div class='pagin'>
        <div style="float:left; margin:0 20px; line-height:36px;">
            共@(Model.TotalItemCount)条数据，每页显示@(Model.PageSize)条，第@(Model.CurrentPageIndex)页/共@(Model.TotalPageCount)页
        </div>
         @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "pageindex", CurrentPagerItemTemplate = "<span class=\"current\">{0}</span>", DisabledPagerItemTemplate = "<span class=\"disabled\">{0}</span>", Id = "badoopager",  AlwaysShowFirstLastPageNumber = true })
    </div>
</div>
<script type="text/javascript">
        $(function () {
            $("#chkall").click(function () {
                if ($(this).prop("checked") == true) {
                    $(".chkitem").prop("checked", true);
                } else {
                    $(".chkitem").prop("checked", false);
                }
            });
        })
        function delmore() {
            if (confirm("是否确认删除所选项？")) {
                var str = "";
                $(".chkitem").each(function (i) {
                    if ($(this).prop("checked") == true) {
                        str += $(this).val() + ",";
                    }
                })
                var url = "/Adnn1n/Video/Delete?ids=" + str;
                $.get(url, function (data) {
                    alert(data);
                    location.reload();
                })
            }

        }
        function delone(id) {
            if (confirm("是否确认删除？")) {
                var url = "/Adnn1n/Video/Delete?ids=" + id;
                $.get(url, function (data) {
                    alert(data);
                    location.reload();
                })
            }
        }
</script>
